home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MISC / SIOD.ARC / !Siod / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1993-03-15  |  24KB  |  810 lines

  1.  >$.TMP.!Sml.!RunImage
  2.  Multitasker for !Sml (c) 1992 Robin Watts
  3.  bent to do Siod 2.09
  4.  screen% 80*32
  5.  indir% 1024
  6.  windata% 4096
  7.  block% 256
  8.  code% 10000
  9.  menublock% 2048
  10.  cblock% 24
  11.  ON ERROR MODE MODE:REPORT:PRINT;" at line ";ERL:END
  12. assemble
  13. initialise
  14. getmodevars
  15. conch
  16. closedown
  17. initialise
  18. "Wimp_Initialise",200,&4B534154,"Siod Tasker" 
  19.  version%,task%
  20. closedown
  21. "Wimp_CloseDown",task%,&4B534154
  22. conch
  23. setup
  24. loadwindows
  25. initmenus
  26. openwindow(mainwh%,
  27. grabcaret
  28. vdu(12)
  29. !ypos=31
  30. launchsiod
  31.  closedown%
  32. closealltasks
  33. setup
  34. size%=(!xmax+1)*(!ymax+1)
  35. closedown%=
  36. !caretowned%=0
  37. prompt%=
  38. taskstarted%=
  39. loadwindows
  40. "Wimp_OpenTemplate",,"<Conch$Dir>.Templates"
  41. 9%mainwh%=
  42. doloadtemplate(0,"main")
  43. :%infowh%=
  44. doloadtemplate(1,"info")
  45. "Wimp_CloseTemplate"
  46. doloadtemplate(n%,ident$)
  47.  whandle%
  48. "Wimp_LoadTemplate",,windata%+n%*2048,indir%+n%*512,indir%+n%*512+512,-1,
  49. ident$+
  50. (0))),0
  51. "Wimp_CreateWindow",,windata%+n%*2048 
  52.  whandle%
  53. =whandle%
  54. openwindow(wh%,tooldsize%)
  55. !block%=wh%
  56.  tooldsize% 
  57. "Wimp_GetWindowInfo",,block%
  58.  block%!28=-1
  59. "Wimp_OpenWindow",,block%
  60. "Wimp_Poll",%110001,block% 
  61.  reason%,block%
  62.  reason% 
  63. redrawwindow
  64. openwindow(!block%,
  65. closealltasks
  66. mouseclicked
  67. keypressed
  68. menuselected
  69. gaincaret
  70. losecaret
  71.  17,18,19
  72.  block%!16 
  73. closealltasks
  74.  &400C1
  75. getmodevars
  76.  &808C1
  77. childoutput
  78.  &808C2
  79. childstarted
  80.  &808C3
  81. childdied
  82. redrawwindow
  83.  "Wimp_RedrawWindow",,block% 
  84.  more%
  85.  more%<>0
  86. t. !minx%=(block%!28-block%!4+block%!20)
  87. u. !maxx%=(block%!36-block%!4+block%!20)
  88. v0 !miny%=-(block%!40-block%!16+block%!24)
  89. w2 !maxy%=-(block%!32-block%!16+block%!24)
  90.  32+1
  91.  redraw
  92.  "Wimp_GetRectangle",,block% 
  93.  more%
  94. closealltasks
  95.  taskstarted% 
  96.  block%!20=1
  97.  block%!16=&808C0
  98.  block%!0=28
  99.  block%!12=0
  100.  block%!24=4
  101. "Wimp_SendMessage",17,block%,handle%
  102.  taskstarted%=
  103. childdied
  104. assemble
  105.  pass%=0 
  106. P%=code%
  107. [OPT pass%
  108. .screen
  109.                  EQUD screen%
  110.                 EQUD 0
  111.     .xmax
  112.                 EQUD 79
  113.     .ymax
  114.                 EQUD 31
  115. .xwinmax
  116.                 EQUD 79
  117. .xwinmin
  118.                 EQUD 0
  119. .ywinmax
  120.                 EQUD 31
  121. .ywinmin
  122.                 EQUD 0
  123.     .xpos
  124.                 EQUD 0
  125.     .ypos
  126.                 EQUD 0
  127. .vdusupressed
  128.                 EQUD 0
  129. .followingbytes
  130.                 EQUD 0
  131. .numbertocome
  132.                 EQUD 0
  133. .queueaddr
  134.                 EQUD queue
  135. .queue
  136.                 EQUD 0
  137.                 EQUD 0
  138.                 EQUD 0
  139.                 EQUD 0
  140. .bytestoignore
  141.                 EQUD 0
  142. H                                        \ Enter with Vdu Char in vdu
  143. @                                        \ No exit Conditions
  144. .dovdu
  145. +                STMFD R13!,{R0-R12,R14}
  146.                 LDRB R0,vdu
  147. (                LDR R1,bytestoignore
  148.                 CMP R1,#0
  149. "                BNE ignorebyte
  150. )                LDR R1,followingbytes
  151.                 CMP R1,#0
  152. !                BNE following
  153. )                CMP R0,#6  :BEQ vduon
  154. '                LDR R1,vdusupressed
  155. +                CMP R1,#1  :BEQ ignore0
  156. *                CMP R0,#127:BEQ delete
  157. -                CMP R0,#32 :BGE printable
  158. +                CMP R0,#0  :BEQ ignore0
  159. 8                CMP R0,#1  :
  160. Q R0,#1     :BEQ ignore
  161. +                CMP R0,#2  :BEQ ignore0
  162. +                CMP R0,#3  :BEQ ignore0
  163. +                CMP R0,#4  :BEQ ignore0
  164. +                CMP R0,#5  :BEQ ignore0
  165. -                CMP R0,#7  :BEQ printable
  166. -                CMP R0,#8  :BEQ backspace
  167. 0                CMP R0,#9  :BEQ forwardspace
  168. ,                CMP R0,#10 :BEQ linefeed
  169. *                CMP R0,#11 :BEQ upline
  170. '                CMP R0,#12 :BEQ cls
  171. +                CMP R0,#13 :BEQ creturn
  172. +                CMP R0,#14 :BEQ ignore0
  173. +                CMP R0,#15 :BEQ ignore0
  174. +                CMP R0,#16 :BEQ ignore0
  175. 8                CMP R0,#17 :
  176. Q R0,#1     :BEQ ignore
  177. 8                CMP R0,#18 :
  178. Q R0,#2     :BEQ ignore
  179. 8                CMP R0,#19 :
  180. Q R0,#5     :BEQ ignore
  181. +                CMP R0,#20 :BEQ ignore0
  182. *                CMP R0,#21 :BEQ vduoff
  183. 8                CMP R0,#22 :
  184. Q R0,#1     :BEQ ignore
  185. 8                CMP R0,#23 :
  186. Q R0,#9     :BEQ ignore
  187. 8                CMP R0,#24 :
  188. Q R0,#8     :BEQ ignore
  189. 8                CMP R0,#25 :
  190. Q R0,#5     :BEQ ignore
  191. )                CMP R0,#26 :BEQ vdu26
  192. +                CMP R0,#27 :BEQ ignore0
  193. .                CMP R0,#28 :BEQ textwindow
  194. 8                CMP R0,#29 :
  195. Q R0,#4     :BEQ ignore
  196. (                CMP R0,#30 :BEQ home
  197. '                CMP R0,#31 :BEQ tab
  198. .ignore0
  199. *                LDMFD R13!,{R0-R12,PC}
  200. .vduon
  201.                 MOV R0,#0
  202. '                STR R0,vdusupressed
  203.                 B   ignore0
  204. .delete
  205. 3                MOV R0,#8  :STR R0,vdu:BL dovdu
  206. 3                MOV R0,#32 :STR R0,vdu:BL dovdu
  207. 3                MOV R0,#8  :STR R0,vdu:BL dovdu
  208.                 LDR R1,xpos
  209.                 LDR R2,ypos
  210. "                BL  changedbox
  211.                 B   ignore0
  212. .backspace
  213.                 LDR R0,xpos
  214.                 LDR R1,ypos
  215. "                LDR R2,xwinmin
  216. "                LDR R3,ywinmin
  217. "                LDR R4,xwinmax
  218. "                LDR R5,ywinmax
  219.                  SUB R0,R0,#1
  220.                 STR R0,xpos
  221.                 CMP R0,R2
  222.                 BGE ignore0
  223.                 MOV R0,R4
  224.                 STR R0,xpos
  225.                  SUB R1,R1,#1
  226.                 STR R1,ypos
  227.                 CMP R1,R3
  228.                 BGE ignore0
  229. )                BL  scrolldownoneline
  230.                 MOV R1,R3
  231.                 STR R1,ypos
  232.                 B   ignore0
  233. .forwardspace
  234.                 LDR R0,xpos
  235.                 LDR R1,ypos
  236. "                LDR R2,xwinmin
  237. "                LDR R3,ywinmin
  238. "                LDR R4,xwinmax
  239. "                LDR R5,ywinmax
  240.                  ADD R0,R0,#1
  241.                 STR R0,xpos
  242.                 CMP R0,R4
  243.                 BLE ignore0
  244.                 MOV R0,R2
  245.                 STR R0,xpos
  246.                  ADD R1,R1,#1
  247.                 STR R1,ypos
  248.                 CMP R1,R5
  249.                 BLE ignore0
  250. '                BL  scrolluponeline
  251.                 MOV R1,R5
  252.                 STR R1,ypos
  253.                 B   ignore0
  254. .linefeed
  255.                 MOV R0,#13
  256.                 STR R0,vdu
  257.                 BL dovdu
  258.                 LDR R0,xpos
  259.                 LDR R1,ypos
  260. $"                LDR R2,xwinmin
  261. %"                LDR R3,ywinmin
  262. &"                LDR R4,xwinmax
  263. '"                LDR R5,ywinmax
  264. (                 ADD R1,R1,#1
  265.                 STR R1,ypos
  266.                 CMP R1,R5
  267.                 BLE ignore0
  268. ,'                BL  scrolluponeline
  269.                 MOV R1,R5
  270.                 STR R1,ypos
  271.                 B   ignore0
  272. .upline
  273.                 LDR R0,xpos
  274.                 LDR R1,ypos
  275. 3"                LDR R2,xwinmin
  276. 4"                LDR R3,ywinmin
  277. 5"                LDR R4,xwinmax
  278. 6"                LDR R5,ywinmax
  279. 7                 SUB R1,R1,#1
  280.                 STR R1,ypos
  281.                 CMP R1,R3
  282.                 BGE ignore0
  283. ;)                BL  scrolldownoneline
  284.                 MOV R1,R3
  285.                 STR R1,ypos
  286.                 B   ignore0
  287. @"                LDR R1,xwinmax
  288. A"                LDR R2,ywinmax
  289. B!                BL changedbox
  290.                 MOV R4,R1
  291.                 MOV R5,R2
  292. E"                LDR R1,xwinmin
  293. F"                LDR R2,ywinmin
  294. G!                BL changedbox
  295.                 MOV R3,R2
  296.                 MOV R2,R1
  297.                 LDR R6,xmax
  298. K                 ADD R6,R6,#1
  299. L!                LDR R8,screen
  300.                 MOV R9,#&20
  301.                 MOV R1,R3
  302. .clslp1
  303.                 MOV R0,R2
  304. .clslp2
  305. R#                MLA R7,R1,R6,R8
  306. S                 ADD R7,R7,R0
  307. T                 STRB R9,[R7]
  308. U                 ADD R0,R0,#1
  309.                 CMP R0,R4
  310.                 BLE clslp2
  311. X                 ADD R1,R1,#1
  312.                 CMP R1,R5
  313.                 BLE clslp1
  314.                 STR R2,xpos
  315.                 STR R3,ypos
  316.                 B   ignore0
  317. .creturn
  318. _"                LDR R0,xwinmin
  319.                 STR R0,xpos
  320.                 B   ignore0
  321. .vduoff
  322.                 MOV R0,#1
  323. d'                STR R0,vdusupressed
  324.                 B   ignore0
  325. .vdu26
  326.                 MOV R0,#0
  327. h"                STR R0,xwinmin
  328. i"                STR R0,ywinmin
  329.                 STR R0,xpos
  330.                 STR R0,ypos
  331.                 LDR R0,xmax
  332. m"                STR R0,xwinmax
  333.                 LDR R0,ymax
  334. o"                STR R0,ywinmax
  335.                 B   ignore0
  336. .textwindow
  337.                 MOV R0,#28
  338. s)                STR R0,followingbytes
  339.                 MOV R0,#4
  340. u'                STR R0,numbertocome
  341.                 B ignore0
  342. .textwindow2
  343. x#                LDRB R0,queue+3
  344. y#                LDRB R1,queue+2
  345. z#                LDRB R2,queue+1
  346. {!                LDRB R3,queue
  347.                 LDR R4,xmax
  348.                 LDR R5,ymax
  349.                 CMP R0,R2
  350.                 BGT ignore0
  351.                 CMP R1,R3
  352.                 BLT ignore0
  353.                 CMP R2,R4
  354.                 BGT ignore0
  355.                 CMP R3,R5
  356.                 BGT ignore0
  357. "                STR R0,xwinmin
  358. "                STR R1,ywinmax
  359. "                STR R2,xwinmax
  360. "                STR R3,xwinmin
  361.                 B ignore0
  362.     .home
  363. "                LDR R0,xwinmin
  364.                 STR R0,xpos
  365. "                LDR R1,ywinmin
  366.                 STR R2,ypos
  367.                 B ignore0
  368.                 MOV R0,#31
  369. )                STR R0,followingbytes
  370.                 MOV R0,#2
  371. '                STR R0,numbertocome
  372.                 B ignore0
  373.     .tab2
  374. #                LDRB R0,queue+1
  375. !                LDRB R1,queue
  376. "                LDR R2,xwinmin
  377. "                LDR R3,ywinmin
  378. "                LDR R4,xwinmax
  379. "                LDR R5,ywinmax
  380.                  ADD R0,R0,R2
  381.                  ADD R1,R1,R3
  382.                 CMP R0,R4
  383.                 BGT ignore0
  384.                 CMP R1,R5
  385.                 BGT ignore0
  386.                 STR R0,xpos
  387.                 STR R1,ypos
  388.                 B ignore0
  389. .ignore
  390. (                STR R0,bytestoignore
  391.                 B ignore0
  392. .ignorebyte
  393.                  SUB R0,R0,#1
  394. (                STR R0,bytestoignore
  395.                 B ignore0
  396. .following
  397. '                LDR R2,numbertocome
  398. $                LDR R3,queueaddr
  399. !                SUBS R2,R2,#1
  400. #                STRB R0,[R3,R2]
  401. '                STR R2,numbertocome
  402.                 BGE ignore0
  403. /                CMP R1,#28 :BEQ textwindow2
  404. (                CMP R1,#31 :BEQ tab2
  405.                 B ignore0
  406. .printable
  407. !                LDR R5,screen
  408.                 LDR R1,xpos
  409.                 LDR R2,ypos
  410. !                BL changedbox
  411.                 LDR R4,xmax
  412.                  ADD R4,R4,#1
  413. #                MLA R5,R4,R2,R5
  414. #                STRB R0,[R5,R1]
  415. "                B forwardspace
  416. .scrolldownoneline
  417. +                STMFD R13!,{R0-R12,R14}
  418. "                LDR R1,xwinmax
  419. "                LDR R2,ywinmax
  420. !                BL changedbox
  421.                 MOV R3,R2
  422. "                LDR R1,xwinmin
  423. "                LDR R2,ywinmin
  424. !                BL changedbox
  425.                 MOV R0,R1
  426.                 MOV R1,R2
  427. "                LDR R2,xwinmax
  428.                 CMP R1,R3
  429. &                BEQ blankfirstline
  430. !                LDR R4,screen
  431.                 LDR R7,xmax
  432.                  ADD R7,R7,#1
  433.                  SUB R8,R3,#1
  434. .sdollp1
  435.                 MOV R9,R0
  436. .sdollp2
  437. #                MLA R6,R7,R8,R4
  438. #                LDRB R5,[R6,R9]
  439.                  ADD R6,R6,R7
  440. #                STRB R5,[R6,R9]
  441.                  ADD R9,R9,#1
  442.                 CMP R9,R7
  443.                 BLE sdollp2
  444.                  SUB R8,R8,#1
  445.                 CMP R8,R1
  446.                 BGE sdollp1
  447. .blankfirstline
  448. #                MLA R6,R7,R1,R4
  449.                 MOV R9,R0
  450.                 MOV R5,#32
  451. .sdollp3
  452. #                STRB R5,[R6,R9]
  453.                  ADD R9,R9,#1
  454.                 CMP R9,R2
  455.                 BLE sdollp3
  456. *                LDMFD R13!,{R0-R12,PC}
  457. .scrolluponeline
  458. +                STMFD R13!,{R0-R12,R14}
  459.                  BL scrollbox
  460. "                LDR R2,xwinmax
  461. "                LDR R3,ywinmax
  462. "                LDR R0,xwinmin
  463. "                LDR R1,ywinmin
  464.                 CMP R1,R3
  465. %                BEQ blanklastline
  466. !                LDR R4,screen
  467.                 LDR R7,xmax
  468.                  ADD R7,R7,#1
  469.                  ADD R8,R1,#1
  470. .suollp1
  471.                 MOV R9,R0
  472. .suollp2
  473. #                MLA R6,R7,R8,R4
  474. #                LDRB R5,[R6,R9]
  475.                  SUB R6,R6,R7
  476. #                STRB R5,[R6,R9]
  477.                  ADD R9,R9,#1
  478.                 CMP R9,R7
  479.                 BLE suollp2
  480.                  ADD R8,R8,#1
  481.                 CMP R8,R3
  482.                 BLE suollp1
  483. .blanklastline
  484. #                MLA R6,R7,R3,R4
  485.                 MOV R9,R0
  486.                 MOV R5,#32
  487. .suollp3
  488. #                STRB R5,[R6,R9]
  489.                  ADD R9,R9,#1
  490.                 CMP R9,R2
  491.                 BLE suollp3
  492. *                LDMFD R13!,{R0-R12,PC}
  493. .changedbox
  494. +                STMFD R13!,{R0-R12,R14}
  495. #                LDR R0,changed%
  496.                 CMP R0,#0
  497. &                BNE changedalready
  498. &                STR R1,changeminx%
  499. &                STR R1,changemaxx%
  500. &                STR R2,changeminy%
  501. &                STR R2,changemaxy%
  502.                 MOV R1,#1
  503. #                STR R1,changed%
  504. *                LDMFD R13!,{R0-R12,PC}
  505. .changedalready
  506. &                LDR R0,changeminx%
  507. 2                CMP R1,R0:STRLT R1,changeminx%
  508. &                LDR R0,changemaxx%
  509. 2                CMP R1,R0:STRGT R1,changemaxx%
  510.  &                LDR R0,changeminy%
  511. !2                CMP R2,R0:STRLT R2,changeminy%
  512. "&                LDR R0,changemaxy%
  513. #2                CMP R2,R0:STRGT R2,changemaxy%
  514. $*                LDMFD R13!,{R0-R12,PC}
  515. .scrollbox
  516. &+                STMFD R13!,{R0-R12,R14}
  517. '#                LDR R0,changed%
  518.                 CMP R0,#0
  519. )+                BLNE changebeforescroll
  520. *$                LDR R0,scrolled%
  521.                 CMP R0,#0
  522. ,                 BNE scrolled
  523. -"                LDR R0,xwinmin
  524. .&                STR R0,scrollminx%
  525. /"                LDR R0,xwinmax
  526. 0&                STR R0,scrollmaxx%
  527. 1"                LDR R0,ywinmin
  528. 2&                STR R0,scrollminy%
  529. 3"                LDR R0,ywinmax
  530. 4&                STR R0,scrollmaxy%
  531.                 MOV R0,#1
  532. 6'                STR R0,scrollcount%
  533. 7$                STR R0,scrolled%
  534. 8*                LDMFD R13!,{R0-R12,PC}
  535. .scrolled
  536. :"                LDR R0,xwinmin
  537. ;&                LDR R1,scrollminx%
  538. <.                CMP R0,R1:BNE scrollnewwin
  539. ="                LDR R0,ywinmin
  540. >&                LDR R1,scrollminy%
  541. ?.                CMP R0,R1:BNE scrollnewwin
  542. @"                LDR R0,xwinmax
  543. A&                LDR R1,scrollmaxx%
  544. B.                CMP R0,R1:BNE scrollnewwin
  545. C"                LDR R0,ywinmax
  546. D&                LDR R1,scrollmaxy%
  547. E.                CMP R0,R1:BNE scrollnewwin
  548. F'                LDR R0,scrollcount%
  549. G                 ADD R0,R0,#1
  550. H'                STR R0,scrollcount%
  551. I*                LDMFD R13!,{R0-R12,PC}
  552. .scrollnewwin
  553. K"                LDR R0,xwinmin
  554. L&                LDR R1,changeminx%
  555. M2                CMP R0,R1:STRLT R0,changeminx%
  556. N"                LDR R0,xwinmax
  557. O&                LDR R1,changemaxx%
  558. P2                CMP R0,R1:STRGT R0,changemaxx%
  559. Q"                LDR R0,ywinmin
  560. R&                LDR R1,changeminy%
  561. S2                CMP R0,R1:STRLT R0,changeminy%
  562. T"                LDR R0,ywinmax
  563. U&                LDR R1,changemaxy%
  564. V2                CMP R0,R1:STRGT R0,changemaxy%
  565. W.                MOV R0,#0:STR R0,scrolled%
  566. X-                MOV R0,#1:STR R0,changed%
  567. Y*                LDMFD R13!,{R0-R12,PC}
  568. .changebeforescroll
  569. [+                STMFD R13!,{R0-R12,R14}
  570. \&                LDR R0,changeminy%
  571. ]                 SUB R0,R0,#1
  572. ^&                STR R0,changeminy%
  573. _*                LDMFD R13!,{R0-R12,PC}
  574. .scrolled%
  575.                 EQUD 0
  576. .scrollminx%
  577.                 EQUD 0
  578. .scrollminy%
  579.                 EQUD 0
  580. .scrollmaxx%
  581.                 EQUD 0
  582. .scrollmaxy%
  583.                 EQUD 0
  584. .scrollcount%
  585.                 EQUD 0
  586. .changed%
  587.                 EQUD 0
  588. .changeminx%
  589.                 EQUD 0
  590. .changeminy%
  591.                 EQUD 0
  592. .changemaxx%
  593.                 EQUD 0
  594. .changemaxy%
  595.                 EQUD 0
  596. .caretowned%
  597.                 EQUD 0
  598. .block
  599.                 EQUD block%
  600. .xpix%
  601.                 EQUD 0
  602. .ypix%
  603.                 EQUD 0
  604. .minx%
  605.                 EQUD 0
  606. .miny%
  607.                 EQUD 0
  608. .maxx%
  609.                 EQUD 0
  610. .maxy%
  611.                 EQUD 0
  612. .double%
  613.                 EQUD 0
  614. .redraw
  615. +                STMFD R13!,{R0-R12,R14}
  616.                  LDR R3,miny%
  617. )                CMP R3,#0:MOVLT R3,#0
  618.                  LDR R4,maxy%
  619.                 LDR R5,ymax
  620. )                CMP R4,R5:MOVGT R4,R5
  621.                  LDR R5,minx%
  622. )                CMP R5,#0:MOVLT R5,#0
  623.                  LDR R6,maxx%
  624.                  LDR R12,xmax
  625. "                ADD R12,R12,#1
  626. +                CMP R6,R12:MOVGT R6,R12
  627.                 MOV R7,#16
  628.                 MOV R8,#32
  629.                  LDR R9,block
  630. "                LDR R11,screen
  631. .redrawlp1
  632.                 MOV R0,#4
  633. #                LDR R10,[R9,#4]
  634. #                LDR R1,[R9,#20]
  635. !                SUB R1,R10,R1
  636. #                MLA R1,R5,R7,R1
  637. $                LDR R10,[R9,#24]
  638. $                MLA R2,R3,R8,R10
  639. $                LDR R10,[R9,#16]
  640. !                SUB R2,R10,R2
  641. !                SWI "OS_Plot"
  642.                 MOV R14,R5
  643. %                MLA R1,R3,R12,R11
  644. .redrawlp2
  645. $                LDRB R0,[R1,R14]
  646. #                SWI "OS_WriteC"
  647. "                ADD R14,R14,#1
  648.                 CMP R14,R6
  649. !                BLE redrawlp2
  650.                  ADD R3,R3,#1
  651.                 CMP R3,R4
  652. !                BLE redrawlp1
  653. *                LDMFD R13!,{R0-R12,PC}
  654. getmodevars
  655. !block%=0
  656. block%!4=4
  657. block%!8=5
  658. block%!12=-1
  659. "OS_ReadVduVariables",block%,block%+40
  660. xeig%=block%!44
  661. yeig%=block%!48
  662. !xpix%=1<<xeig%
  663. !ypix%=1<<yeig%
  664. "!double%=((block%!40) 
  665.  32)>>5
  666. grabcaret
  667. "Wimp_SetCaretPosition",mainwh%,-1,!xpos*8*!xpix%,-(!ypos+1)*32,32,0
  668. !caretowned%=1
  669. gaincaret
  670. losecaret
  671. mouseclicked
  672.  button%
  673. button%=block%!8
  674.  (button% 
  675.  4)=4 
  676. grabcaret
  677.  (button% 
  678.  2)=2 
  679. popupmenu
  680. popdownmenu
  681. keypressed
  682.  char%
  683. char%=block%!24
  684.  !block%=mainwh% 
  685.  char%=(char% 
  686.  255) 
  687.   block%!20=1
  688.   block%!16=&808C0
  689.   block%!0=28
  690.   block%!12=0
  691.   block%!24=char%
  692. "Wimp_SendMessage",17,block%,handle%
  693. "Wimp_ProcessKey",block%!24
  694. "Wimp_ProcessKey",block%!24
  695. launchsiod
  696. taskwindow("<Siod$Dir>.!Siod209 -i<Scm$Dir>.siod_scm -h20000")
  697. taskwindow(str$)
  698.  command$
  699. {command$="TaskWindow """+str$+""" -quit -wimpslot 640K -name ""Siod Engine"" -task &"+
  700. ~(task%)+" -txt &00000000 -ctrl"
  701. "Wimp_StartTask",command$
  702. childstarted
  703. handle%=block%!4
  704. inputto%=block%!20
  705. taskstarted%=
  706. childoutput
  707. dovduat(block%+20)
  708. dovduat(addr%)
  709.  "Wimp_GetCaretPosition",,cblock%
  710.  !cblock%=mainwh% 
  711.  !caretowned%=1
  712.  !caretowned%=0
  713. !changed%=0
  714. !scrolled%=0
  715.  l%=0 
  716.  (!addr%)-1
  717.  !vdu=l%?(addr%+4)
  718.  dovdu
  719.  !scrolled%>0 
  720.  !caretowned% 
  721.  "Wimp_SetCaretPosition",mainwh%,-1,-100,-100,32,0
  722.  "Wimp_BlockCopy",mainwh%,!scrollminx%*16,-(!scrollmaxy%+1)*32,(!scrollmaxx%+1)*16,-!scrollminy%*32+!ypix%-!scrollcount%*32,!scrollminx%*16,-(!scrollmaxy%+1)*32+!scrollcount%*32
  723.  "Wimp_ForceRedraw",mainwh%,!scrollminx%*16,-(!scrollmaxy%+1)*32,(!scrollmaxx%+1)*16,-(!scrollmaxy%+1)*32+!scrollcount%*32
  724.  !caretowned% 
  725. "Wimp_SetCaretPosition",mainwh%,-1,!xpos*8*!xpix%,-(!ypos+1)*32,32,0
  726.  !changed%>0 
  727.  "Wimp_ForceRedraw",mainwh%,!changeminx%*16,-(!changemaxy%+1)*32,(!changemaxx%+1)*16,-!changeminy%*32+!ypix%
  728.  !caretowned% 
  729.  !scrolled% 
  730. "Wimp_SetCaretPosition",mainwh%,-1,!xpos*8*!xpix%,-(!ypos+1)*32,32,0
  731. vdu(n%)
  732. !changed%=0
  733. !vdu=n%
  734.  dovdu
  735.  !changed%>0 
  736.  "Wimp_ForceRedraw",mainwh%,!changeminx%*8*!xpix%,-(!changemaxy%+1)*(8<<!double%)*!ypix%,(!changemaxx%+1)*8*!xpix%,-!changeminy%*(8<<!double%)*!ypix%+!ypix%
  737. childdied
  738.  "Wimp_GetCaretPosition",,cblock%
  739.  !cblock%=mainwh% 
  740.  "Wimp_SetCaretPosition",-1
  741. closedown%=
  742. initmenus
  743. menuendptr%=menublock%+64
  744. makemenu("Siod|Info|Quit",menuendptr%,0,menublock%)
  745. attachwindow(infowh%,0,0)
  746. makemenu(str$,
  747.  ptr%,no%,menublock%)
  748.  str1$,off%
  749. str$+="|"
  750. menublock%!(no%<<2)=ptr%
  751. str1$=
  752. slice(str$)
  753. $ptr%=str1$
  754. 8+ptr%?12=7:ptr%?13=2:ptr%?14=7:ptr%?15=0
  755. ptr%!16=12*16
  756. ptr%!20=44
  757. ptr%!24=0
  758. off%=28
  759.  str1$=
  760. slice(str$)
  761.  ptr%!off%=0
  762.  str$="" 
  763.  ptr%!off%=ptr%!off% 
  764.  (1<<7)
  765.  ptr%!(off%+4)=-1
  766. B- ptr%!(off%+8)=&10021 + (7<<24) + (0<<28)
  767. str1$,1) 
  768.    str1$=
  769. str1$,2)
  770. F#   ptr%!off%=ptr%!off% 
  771.  (1<<2)
  772. G+   ptr%!(off%+8)=ptr%!(off%+8) 
  773.  (1<<8)
  774. H.   ptr%!(off%+12)=
  775. str1$,
  776. str1$,",")-1))
  777.    ptr%!(off%+16)=0
  778. J.   ptr%!(off%+20)=
  779. str1$,
  780. str1$,",")+1))
  781.   $(ptr%+off%+12)=str1$
  782.  off%+=24
  783.  str$=""
  784. ptr%+=off%
  785. attachmenu(submenu%,item%,parentmenu%)
  786.  ptr%
  787. U$ptr%=menublock%!(parentmenu%<<2)
  788. V/ptr%!(32+item%*24)=menublock%!(submenu%<<2)
  789. attachwindow(window%,item%,parentmenu%)
  790.  ptr%
  791. [$ptr%=menublock%!(parentmenu%<<2)
  792. ptr%!(32+item%*24)=window%
  793. slice(
  794.  str$)
  795.  return$
  796. return$=
  797. str$,
  798. str$,"|")-1)
  799. str$=
  800. str$,
  801. str$,"|")+1)
  802. =return$
  803. popupmenu
  804. "Wimp_CreateMenu",,menublock%+64,(block%!0)-64,(block%!4)
  805. popdownmenu
  806. "Wimp_CreateMenu",,-1
  807. menuselected
  808.  block%!0 
  809. closealltasks
  810.